package cn.edu.ctbu.firstdp.dao;

import cn.edu.ctbu.firstdp.entity.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
public interface TeacherRepository extends JpaRepository<Teacher,Integer> {

    //本地SQL查询
    //查找最大工号
    @Query(nativeQuery = true,value = "select * from tb_teacher t where " +
            "substring(t.tno, 1, 4) = (select MAX(substring(t1.tno, 1, 4)) from tb_teacher t1)")
    List<Teacher> findTeacherWithMaxPrefixTno();

    //按名字查询教师
    List<Teacher> findByNameLike(String name);



}

